package models

import (
	"192.168.1.75/go-pkg/helper"
	"gorm.io/gorm"
)

// GoodsReviewAuditLog 商品评测审核日志
type GoodsReviewAuditLog struct {
	ID          string `json:"id" gorm:"primaryKey;column:id;type:bigint"`
	ReviewID    string `json:"review_id" gorm:"column:review_id;type:int;size:64;comment:评测id"`
	AuditStatus int    `json:"audit_status" gorm:"column:audit_status;type:int;size:8;default:1;comment:审核状态 1-审核通过 2-审核未通过"`
	AuditUserID string `json:"audit_user_id" gorm:"column:audit_user_id;type:int;size:64;comment:审核人"`
	Reason      string `json:"reason" gorm:"column:reason;type:text;size:100;comment:审核未通过原因"`
	Points      int    `json:"points" gorm:"column:points;type:int;size:32;comment:赠送的积分"`
	CreatedAt   int64  `json:"created_at" gorm:"column:created_at;autoCreateTime;type:int;size:64;index:idx_createdAt;comment:创建时间"`
}

func (GoodsReviewAuditLog) TableName() string {
	return "goods_review_audit_log"
}

// BeforeCreate 自增id
func (m *GoodsReviewAuditLog) BeforeCreate(tx *gorm.DB) (err error) {
	if m.ID != "" {
		return nil
	}
	// 用户id为空时，自动添加用户id
	uuid, err := helper.UUID{}.String()
	if err != nil {
		return err
	}
	m.ID = uuid
	return nil
}

// 模式自动注册
func init() {
	Models = append(Models, &GoodsReviewAuditLog{})
}
